<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>注册</title>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
</head>
<body>
<form action="/api/register-action" method="post">
    用户名<input name="name" type="text"/><br/>
    邮箱<input id="mail" name="mail" type="text"><br/>
    邮箱验证码<input name="validCode" type="text">
    <button id="send-button" type="button">发送验证码</button>
    <br/>
    密码<input name="password" type="text"><br/>
    验证码<input name="code" type="text"><img src="" id="picCode"/><a href="javascript:reloadCode();">重新获取验证码</a>
    <br/>
    <input type="hidden" name="uuid" id="uuid" value="">
    <button id="button" type="submit">注册</button>
    <br/>
</form>
<script>
    $("#send-button").click(function () {
        $.get('/api/auth/send-code', {
            mail: $("#mail").val()
        });
    });

    function reloadCode() {
        const time = new Date().getTime();
        document.getElementById("picCode").src = "/api/common-code?d=" + time;
        $.get('/api/common-code', (data) => {
            $("#uuid").val(data.obj);
        })
    }
</script>
</body>
</html>